﻿using System;

namespace Program12
{
    class Program
    {
        /// <summary>
        /// 递归与非递归的遍历密码组合
        /// (穷举法)
        /// </summary>
        /// <param name="args"></param>
        /// 


        public static string[] ABC = new string[] { "A", "B", "C" };
        static void Main(string[] args)
        {
            Enumeration enu = new Enumeration();
            enu.EnumerationRecursive(3);
        }

        public static int EnumerationNotRecursive() 
        {
            string[] abc = new string[] {"A","B","C"};
            int ii = 0;
            for (int i = 0;i < 3; i++)
            {
                for (int x = 0; x < 3; x++)
                {
                    for (int y = 0; y < 3; y++)
                    {
                        ++ii;               
                        Console.WriteLine(abc[i] + abc[x] + abc[y]);
                    }
                    
                }

            }
            return ii;
        }

    
    }
    class Enumeration 
    {
        public int systeam;
        public string[] abc= new string[] { "A", "B", "C" };
        public Enumeration() { }
        public Enumeration(string[] abcString) 
        {
            abc = abcString;
        }
        private int EnumerationRecursive(int a, int b, int c)
        {
            Console.WriteLine(abc[a-1] + "," + abc[b - 1] + "," + abc[c - 1]);

            if (c != 1)
            {
                return EnumerationRecursive(a, b, c - 1);
            }
            if (b != 1)
            {
                c = systeam;
                return EnumerationRecursive(a, b - 1, c);
            }
            if (a != 1)
            {
                b = systeam;
                c = systeam;
                return EnumerationRecursive(a - 1, b, c);
            }
            else
            {

                return 1;
            }

        }
        public void EnumerationRecursive(int SysteamValue) 
        {
           
            Enumeration enumeration = new Enumeration();
            enumeration.systeam = SysteamValue;
            enumeration.EnumerationRecursive(SysteamValue, SysteamValue, SysteamValue);         
        }
    }
}
